{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { useRef, useCallback } from 'react';\nimport warning from \"rc-util/es/warning\";\nimport { nextSlice } from \"../utils/timeUtil\";\nvar PATH_SPLIT = '__RC_UTIL_PATH_SPLIT__';\nvar getPathStr = function getPathStr(keyPath) {\n  return keyPath.join(PATH_SPLIT);\n};\nvar getPathKeys = function getPathKeys(keyPathStr) {\n  return keyPathStr.split(PATH_SPLIT);\n};\nexport var OVERFLOW_KEY = 'rc-menu-more';\nexport default function useKeyRecords() {\n  var _React$useState = React.useState({}),\n    _React$useState2 = _slicedToArray(_React$useState, 2),\n    internalForceUpdate = _React$useState2[1];\n  var key2pathRef = useRef(new Map());\n  var path2keyRef = useRef(new Map());\n  var _React$useState3 = React.useState([]),\n    _React$useState4 = _slicedToArray(_React$useState3, 2),\n    overflowKeys = _React$useState4[0],\n    setOverflowKeys = _React$useState4[1];\n  var updateRef = useRef(0);\n  var destroyRef = useRef(false);\n  var forceUpdate = function forceUpdate() {\n    if (!destroyRef.current) {\n      internalForceUpdate({});\n    }\n  };\n  var registerPath = useCallback(function (key, keyPath) {\n    // Warning for invalidate or duplicated `key`\n    if (process.env.NODE_ENV !== 'production') {\n      warning(!key2pathRef.current.has(key), \"Duplicated key '\".concat(key, \"' used in Menu by path [\").concat(keyPath.join(' > '), \"]\"));\n    } // Fill map\n\n    var connectedPath = getPathStr(keyPath);\n    path2keyRef.current.set(connectedPath, key);\n    key2pathRef.current.set(key, connectedPath);\n    updateRef.current += 1;\n    var id = updateRef.current;\n    nextSlice(function () {\n      if (id === updateRef.current) {\n        forceUpdate();\n      }\n    });\n  }, []);\n  var unregisterPath = useCallback(function (key, keyPath) {\n    var connectedPath = getPathStr(keyPath);\n    path2keyRef.current.delete(connectedPath);\n    key2pathRef.current.delete(key);\n  }, []);\n  var refreshOverflowKeys = useCallback(function (keys) {\n    setOverflowKeys(keys);\n  }, []);\n  var getKeyPath = useCallback(function (eventKey, includeOverflow) {\n    var fullPath = key2pathRef.current.get(eventKey) || '';\n    var keys = getPathKeys(fullPath);\n    if (includeOverflow && overflowKeys.includes(keys[0])) {\n      keys.unshift(OVERFLOW_KEY);\n    }\n    return keys;\n  }, [overflowKeys]);\n  var isSubPathKey = useCallback(function (pathKeys, eventKey) {\n    return pathKeys.some(function (pathKey) {\n      var pathKeyList = getKeyPath(pathKey, true);\n      return pathKeyList.includes(eventKey);\n    });\n  }, [getKeyPath]);\n  var getKeys = function getKeys() {\n    var keys = _toConsumableArray(key2pathRef.current.keys());\n    if (overflowKeys.length) {\n      keys.push(OVERFLOW_KEY);\n    }\n    return keys;\n  };\n  /**\n   * Find current key related child path keys\n   */\n\n  var getSubPathKeys = useCallback(function (key) {\n    var connectedPath = \"\".concat(key2pathRef.current.get(key)).concat(PATH_SPLIT);\n    var pathKeys = new Set();\n    _toConsumableArray(path2keyRef.current.keys()).forEach(function (pathKey) {\n      if (pathKey.startsWith(connectedPath)) {\n        pathKeys.add(path2keyRef.current.get(pathKey));\n      }\n    });\n    return pathKeys;\n  }, []);\n  React.useEffect(function () {\n    return function () {\n      destroyRef.current = true;\n    };\n  }, []);\n  return {\n    // Register\n    registerPath: registerPath,\n    unregisterPath: unregisterPath,\n    refreshOverflowKeys: refreshOverflowKeys,\n    // Util\n    isSubPathKey: isSubPathKey,\n    getKeyPath: getKeyPath,\n    getKeys: getKeys,\n    getSubPathKeys: getSubPathKeys\n  };\n}","map":{"version":3,"names":["_toConsumableArray","_slicedToArray","React","useRef","useCallback","warning","nextSlice","PATH_SPLIT","getPathStr","keyPath","join","getPathKeys","keyPathStr","split","OVERFLOW_KEY","useKeyRecords","_React$useState","useState","_React$useState2","internalForceUpdate","key2pathRef","Map","path2keyRef","_React$useState3","_React$useState4","overflowKeys","setOverflowKeys","updateRef","destroyRef","forceUpdate","current","registerPath","key","process","env","NODE_ENV","has","concat","connectedPath","set","id","unregisterPath","delete","refreshOverflowKeys","keys","getKeyPath","eventKey","includeOverflow","fullPath","get","includes","unshift","isSubPathKey","pathKeys","some","pathKey","pathKeyList","getKeys","length","push","getSubPathKeys","Set","forEach","startsWith","add","useEffect"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-menu/es/hooks/useKeyRecords.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { useRef, useCallback } from 'react';\nimport warning from \"rc-util/es/warning\";\nimport { nextSlice } from \"../utils/timeUtil\";\nvar PATH_SPLIT = '__RC_UTIL_PATH_SPLIT__';\n\nvar getPathStr = function getPathStr(keyPath) {\n  return keyPath.join(PATH_SPLIT);\n};\n\nvar getPathKeys = function getPathKeys(keyPathStr) {\n  return keyPathStr.split(PATH_SPLIT);\n};\n\nexport var OVERFLOW_KEY = 'rc-menu-more';\nexport default function useKeyRecords() {\n  var _React$useState = React.useState({}),\n      _React$useState2 = _slicedToArray(_React$useState, 2),\n      internalForceUpdate = _React$useState2[1];\n\n  var key2pathRef = useRef(new Map());\n  var path2keyRef = useRef(new Map());\n\n  var _React$useState3 = React.useState([]),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      overflowKeys = _React$useState4[0],\n      setOverflowKeys = _React$useState4[1];\n\n  var updateRef = useRef(0);\n  var destroyRef = useRef(false);\n\n  var forceUpdate = function forceUpdate() {\n    if (!destroyRef.current) {\n      internalForceUpdate({});\n    }\n  };\n\n  var registerPath = useCallback(function (key, keyPath) {\n    // Warning for invalidate or duplicated `key`\n    if (process.env.NODE_ENV !== 'production') {\n      warning(!key2pathRef.current.has(key), \"Duplicated key '\".concat(key, \"' used in Menu by path [\").concat(keyPath.join(' > '), \"]\"));\n    } // Fill map\n\n\n    var connectedPath = getPathStr(keyPath);\n    path2keyRef.current.set(connectedPath, key);\n    key2pathRef.current.set(key, connectedPath);\n    updateRef.current += 1;\n    var id = updateRef.current;\n    nextSlice(function () {\n      if (id === updateRef.current) {\n        forceUpdate();\n      }\n    });\n  }, []);\n  var unregisterPath = useCallback(function (key, keyPath) {\n    var connectedPath = getPathStr(keyPath);\n    path2keyRef.current.delete(connectedPath);\n    key2pathRef.current.delete(key);\n  }, []);\n  var refreshOverflowKeys = useCallback(function (keys) {\n    setOverflowKeys(keys);\n  }, []);\n  var getKeyPath = useCallback(function (eventKey, includeOverflow) {\n    var fullPath = key2pathRef.current.get(eventKey) || '';\n    var keys = getPathKeys(fullPath);\n\n    if (includeOverflow && overflowKeys.includes(keys[0])) {\n      keys.unshift(OVERFLOW_KEY);\n    }\n\n    return keys;\n  }, [overflowKeys]);\n  var isSubPathKey = useCallback(function (pathKeys, eventKey) {\n    return pathKeys.some(function (pathKey) {\n      var pathKeyList = getKeyPath(pathKey, true);\n      return pathKeyList.includes(eventKey);\n    });\n  }, [getKeyPath]);\n\n  var getKeys = function getKeys() {\n    var keys = _toConsumableArray(key2pathRef.current.keys());\n\n    if (overflowKeys.length) {\n      keys.push(OVERFLOW_KEY);\n    }\n\n    return keys;\n  };\n  /**\n   * Find current key related child path keys\n   */\n\n\n  var getSubPathKeys = useCallback(function (key) {\n    var connectedPath = \"\".concat(key2pathRef.current.get(key)).concat(PATH_SPLIT);\n    var pathKeys = new Set();\n\n    _toConsumableArray(path2keyRef.current.keys()).forEach(function (pathKey) {\n      if (pathKey.startsWith(connectedPath)) {\n        pathKeys.add(path2keyRef.current.get(pathKey));\n      }\n    });\n\n    return pathKeys;\n  }, []);\n  React.useEffect(function () {\n    return function () {\n      destroyRef.current = true;\n    };\n  }, []);\n  return {\n    // Register\n    registerPath: registerPath,\n    unregisterPath: unregisterPath,\n    refreshOverflowKeys: refreshOverflowKeys,\n    // Util\n    isSubPathKey: isSubPathKey,\n    getKeyPath: getKeyPath,\n    getKeys: getKeys,\n    getSubPathKeys: getSubPathKeys\n  };\n}"],"mappings":"AAAA,OAA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